﻿using aier.dataaccess.model;
using aier.dataaccess.dapper;
using aier.wx.nosql.redis;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace aier.business.logic
{
    public class HospitalBll
    {
        public HospitalDal hospitalDal { get; set; }

        public RedisTestDal redisTestDal { get; set; }

        public List<HospitalView> GetAllHospital()
        {
            List<HospitalView> result = null;
            result = redisTestDal.Get<List<HospitalView>>("HospitalView");

            if (result != null && result.Count() > 0)
            {
                return result;
            }
            else
            {
                result = hospitalDal.GetAllHospital();
                redisTestDal.Set<List<HospitalView>>("HospitalView", result);

            }
            return result;
        }

        /// <summary>
        /// 根据医院ID查询医院信息
        /// </summary>
        /// <param name="hospitalId">医院ID</param>
        /// <returns></returns>
        public HospitalView GetHospitalById(Guid hospitalId)
        {
            return hospitalDal.GetHospitalById(hospitalId);
        }
    }
}
